<!DOCTYPE html>
<html>
<head>
	<include file="Public:common-css" />
	<link type="text/css" rel="stylesheet" href="__ICSS__/member.css" />
</head>
<body>
<div class="container">
<!-------------------------header--------------------------------->
<include file="Public:header" />
<!--------------------------content------------------------------->
	<div class="clr"></div>
    <div class="content">
    	<include file="Public:member-left" />
        <div class="member-right">
        	<div class="member-breadcrumbs">
            	<a href="__ROOT__">首页</a>
                &gt;
                <span>个人中心</span>
                &gt;
                <span>收货地址</span>
            </div>
            <div class="clr"></div>
          	<div class="m-box">
          		<div class="member-address-box">
          			<div class="member-address-title">
          				<strong>收货地址</strong>
          				<a href="javascript:void(0)" id="add">添加新地址</a>
          			</div>
          			<div class="clr"></div>
          			<div class="member-address-content">
          				<ul>
          					<foreach item="list" name="list">
	    						<li <if condition="$list.is_main eq 1">class="on"</if>>
	    							<div class="address-name"><{$list.contact_name}></div>
	    							<div class="address-tel"><{$list.contact_tel}></div>
	    							<div class="address-address"><span><{$list.province}><{$list.city}><{$list.area}><notempty name="list.school_id"><{$list.schoolName}></notempty><{$list.address}></span><if condition="$list.is_main eq 1"><i>默认地址</i></if></div>
	    							<div class="address-icons"><i class="address-icon <empty name='list.school_id'>address-exp-icon<else/>address-school-icon</empty>"></i></div>
	    							<div class="address-default"><if condition="$list.is_main != 1"><a href="javascript:void(0)" onclick="setMain(this)" ref="<{$list.id}>">设为默认地址</a></if></div>
	    							<div class="address-cog"><a href="javascript:void(0)" onclick="edit(this)" ref="<{$list.id}>">修改</a><a href="javascript:void(0)" onclick="del(this)" ref="<{$list.id}>">删除</a></div>
	    							<div class="select-icon"></div>
	    						</li>
    						</foreach>
    						<empty name="list"><p class="no-more-box"><img src="__IIMG__/no-address.png" width="80"/><span>没有收货地址</span></p></empty>
    					</ul>
          			</div>
          		</div>
            </div>
        </div>
    </div>
    <div class="clr"></div>
<!--------------------------content-end--------------------------->
    <include file="Public:footer" />
</div>

</body>
<include file="Public:common-js" />
<script>
	$(function() {
		$("#add").click(function() {
			layerDialog("新增地址",'__URL__/addAddress',"720px","530px",true);
		})
	})
	//修改
	function edit(t){
		layerDialog("修改地址",'__URL__/editAddress?id='+ $(t).attr("ref"),"720px","530px",true);
	}
	//删除
	function del(t){
		$.ajax({
			url:"__URL__/delAddress",
			type:"post",
			data:{'id':$(t).attr("ref")},
			success:function(data){
				var data = eval("("+data+")");
				if(data.status == 1){
					layer.msg(data.info);
					window.location.reload();
				}else{
					layer.msg(data.info);
				}
			}
		})
	}
	//设为默认
	function setMain(t){
		$.ajax({
			url:"__URL__/setDefaultAddress",
			type:"post",
			data:{'id':$(t).attr("ref")},
			success:function(data){
				var data = eval("("+data+")");
				if(data.status == 1){
					layer.msg(data.info);
					window.location.reload();
				}else{
					layer.msg(data.info);
				}
			}
		})
	}
</script>
</html>
